// 版权归 瞄你个汪 所有。使用本代码应遵守相关法律法规和Apache 2.0开源许可要求。
package top.geeke.entity;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.type.JdbcType;
import top.geeke.entity.base.EntityBaseId;
import top.geeke.eunm.SysStatusEnum;
import top.geeke.eunm.SysTenantTypeEnum;
import top.geeke.toolkit.supertable.annotation.SuperColumn;
import top.geeke.toolkit.supertable.annotation.SuperIndex;
import top.geeke.toolkit.supertable.annotation.SuperTable;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 系统租户表
 * </p>
 * @author 瞄你个汪
 * @since 2024-05-01 12:00:00
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_tenant")
@SuperTable(value = "系统租户表", isSystem = true, indexes = {
        @SuperIndex(indexName ="sys_index_{table}_C", indexFields ="code", isUnique = true)
})
public class SysTenant extends EntityBaseId implements Serializable {
    private static final long serialVersionUID = 1L;

    @SuperColumn(value = "应用ID")
    private Long appId;

    @SuperColumn(value = "用户ID")
    private Long userId;

    @SuperColumn(value = "机构ID")
    private Long orgId;

    @SuperColumn(value = "编码", length = 16)
    private String code;

    @SuperColumn(value = "主机", nullable = true, length = 128)
    private String host;

    @SuperColumn(value = "租户类型")
    private SysTenantTypeEnum tenantType;

    @SuperColumn(value = "数据库类型")
    private DbType dbType;

    @SuperColumn(value = "数据库连接", nullable = true)
    private String connection;

    @SuperColumn(value = "数据库标识", nullable = true, length = 64)
    private String configId;

    @SuperColumn(value = "从库连接/读写分离", columType = JdbcType.LONGVARCHAR, nullable = true)
    private String slaveConnections;

    @SuperColumn(value = "有效时间", nullable = true)
    private LocalDateTime expiredDate;

    @SuperColumn(value = "状态")
    private SysStatusEnum status = SysStatusEnum.Enabled;

    @SuperColumn(value = "排序", defaultValue = "100")
    private Integer orderNo = 100;

    @SuperColumn(value = "备注", nullable = true, length = 128)
    private String remark;

    @JsonIgnore
    @JsonIgnoreProperties
    @TableField(exist = false)
    private SysUser user;

    @JsonIgnore
    @JsonIgnoreProperties
    @TableField(exist = false)
    private SysOrg org;

    @JsonIgnore
    @JsonIgnoreProperties
    @TableField(exist = false)
    private SysApp app;
}
